home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / soundkit / Sound.h < prev    next >
Text File  |  1992-02-09  |  5KB  |  177 lines

  1. /*
  2.     Sound.h
  3.     Sound Kit, Release 2.0
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #import <objc/Object.h>
  8. #import <objc/hashtable.h>
  9. #import <objc/NXBundle.h>
  10. #import <streams/streams.h>
  11. #import <sound/sound.h>
  12.  
  13. @class Pasteboard;
  14.  
  15. /* Define this for compatibility */
  16. #define NXSoundPboard NXSoundPboardType
  17.  
  18. extern NXAtom NXSoundPboardType;
  19. /*
  20.  * This is the sound pasteboard type.
  21.  */
  22.  
  23. @interface Sound : Object
  24. /*
  25.  * The Sound object encapsulates a SNDSoundStruct, which represents a sound.
  26.  * It supports reading and writing to a soundfile, playback of sound,
  27.  * recording of sampled sound, conversion among various sampled formats, 
  28.  * basic editing of the sound, and name and storage management for sounds.
  29.  */
  30.  {
  31.     SNDSoundStruct *soundStruct; /* the sound data structure */
  32.     int soundStructSize;     /* the length of the structure in bytes */
  33.     int priority;         /* the priority of the sound */
  34.     id delegate;         /* the target of notification messages */
  35.     int status;             /* what the object is currently doing */
  36.     char *name;             /* The name of the sound */
  37.     SNDSoundStruct *_scratchSound;
  38.     int _scratchSize;
  39. }
  40.  
  41. /*
  42.  * Status codes
  43.  */
  44. typedef enum {
  45.     NX_SoundStopped = 0,
  46.     NX_SoundRecording,
  47.     NX_SoundPlaying,
  48.     NX_SoundInitialized,
  49.     NX_SoundRecordingPaused,
  50.     NX_SoundPlayingPaused,
  51.     NX_SoundRecordingPending,
  52.     NX_SoundPlayingPending,
  53.     NX_SoundFreed = -1,
  54. } NXSoundStatus;
  55.  
  56. /*
  57.  * OBSOLETE status codes - use the NX ones above.
  58.  */
  59. typedef enum {
  60.     SK_STATUS_STOPPED = NX_SoundStopped,
  61.     SK_STATUS_RECORDING = NX_SoundRecording,
  62.     SK_STATUS_PLAYING = NX_SoundPlaying,
  63.     SK_STATUS_INITIALIZED = NX_SoundInitialized,
  64.     SK_STATUS_RECORDING_PAUSED = NX_SoundRecordingPaused,
  65.     SK_STATUS_PLAYING_PAUSED = NX_SoundPlayingPaused,
  66.     SK_STATUS_RECORDING_PENDING = NX_SoundRecordingPending,
  67.     SK_STATUS_PLAYING_PENDING = NX_SoundPlayingPending,
  68.     SK_STATUS_FREED = NX_SoundFreed,
  69. } SKStatus;
  70.  
  71. /*
  72.  * Macho segment name where sounds may be.
  73.  */
  74. #define NX_SOUND_SEGMENT_NAME "__SND"
  75.  
  76. /*
  77.  * OBSOLETE macho segment name - use the NX one above.
  78.  */
  79. #define SK_SEGMENT_NAME "__SND"
  80.  
  81.  
  82. /*
  83.  * --------------- Factory Methods
  84.  */
  85.  
  86. + findSoundFor:(const char *)aName;
  87.  
  88. + addName:(const char *)name sound:aSound;
  89. + addName:(const char *)name fromSoundfile:(const char *)filename;
  90. + addName:(const char *)name fromSection:(const char *)sectionName;
  91. + addName:(const char *)aName fromBundle:(NXBundle *)aBundle;
  92.  
  93. + removeSoundForName:(const char *)name;
  94.  
  95. + getVolume:(float *)left :(float *)right;
  96. + setVolume:(float)left :(float)right;
  97. + (BOOL)isMuted;
  98. + setMute:(BOOL)aFlag;
  99.  
  100. - initFromSoundfile:(const char *)filename;
  101. - initFromSection:(const char *)sectionName;
  102. - initFromPasteboard: (Pasteboard *)thePboard;
  103.  
  104. - free;
  105. - readSoundFromStream:(NXStream *)stream;
  106. - writeSoundToStream:(NXStream *)stream;
  107. - write:(NXTypedStream *) stream;
  108. - read:(NXTypedStream *) stream;
  109. - finishUnarchiving;
  110. - (const char *)name;
  111. - setName:(const char *)theName;
  112. - delegate;
  113. - setDelegate:anObject;
  114. - (double)samplingRate;
  115. - (int)sampleCount;
  116. - (double)duration;
  117. - (int)channelCount;
  118. - (char *)info;
  119. - (int)infoSize;
  120. - play:sender;
  121. - (int)play;
  122. - record:sender;
  123. - (int)record;
  124. - (int)samplesProcessed;
  125. - (int)status;
  126. - (int)waitUntilStopped;
  127. - stop:sender;
  128. - (int)stop;
  129. - pause:sender;
  130. - (int)pause;
  131. - resume:sender;
  132. - (int)resume;
  133. - (int)readSoundfile:(const char *)filename;
  134. - (int)writeSoundfile:(const char *)filename;
  135. - (int)writeToPasteboard:(Pasteboard *)thePboard;
  136. - (BOOL)isEmpty;
  137. - (BOOL)isEditable;
  138. - (BOOL)compatibleWith:aSound;
  139. - (BOOL)isPlayable;
  140. - (int)convertToFormat:(int)aFormat
  141.        samplingRate:(double)aRate
  142.        channelCount:(int)aChannelCount;
  143. - (int)convertToFormat:(int)aFormat;
  144. - (int)deleteSamples;
  145. - (int)deleteSamplesAt:(int)startSample count:(int)sampleCount;
  146. - (int)insertSamples:aSound at:(int)startSample;
  147. - (int)copySound:aSound;
  148. - (int)copySamples:aSound at:(int)startSample count:(int)sampleCount;
  149. - (int)compactSamples;
  150. - (BOOL)needsCompacting;
  151. - (unsigned char *)data;
  152. - (int)dataSize;
  153. - (int)dataFormat;
  154. - (int)setDataSize:(int)newDataSize
  155.      dataFormat:(int)newDataFormat
  156.      samplingRate:(double)newSamplingRate
  157.      channelCount:(int)newChannelCount
  158.      infoSize:(int)newInfoSize;
  159. - (SNDSoundStruct *)soundStruct;
  160. - (int)soundStructSize;
  161. - setSoundStruct:(SNDSoundStruct *)aStruct soundStructSize:(int)aSize;
  162. - (SNDSoundStruct *)soundStructBeingProcessed;
  163. - (int)processingError;
  164. - soundBeingProcessed;
  165. - tellDelegate:(SEL)theMessage;
  166.  
  167. @end
  168.  
  169. @interface SoundDelegate : Object
  170. - willRecord:sender;
  171. - didRecord:sender;
  172. - willPlay:sender;
  173. - didPlay:sender;
  174. - hadError:sender;
  175. @end
  176.  
  177.